

# 1.求100以内的素数;>1整数，只能被1和自己整除
#
# for i in range(2,100):
#     for j in range(2,i//2):
#         if i%j==0:
#             break
#         elif j==i//2-1:
#             print(i)
#         else:
#             continue

# for i in range(2, 100):
#     for j in range(2,i):
#         if i % j == 0:
#             break
#     else:
#         print(i,end=' ')
# print()

for m in range(2,100):
    if m==2:
        print(m,end=' ')
    else:
        for n in range(2,m):
            if m%n==0:
                break
        else:
            print(m,end=' ')
            
print()


# 2.随机产生20个100-200之间的正整数存放到列表中，
# 并求列表中的所有元素最大值、最小值、平均值，然后将各元素的与平均值的差组成一个列表
import random
l1=random.sample(range(100,200),20)
print(l1)
print('最大值为：{}'.format(max(l1)))
print('最小值为：',min(l1))
# sum=0
# for i in range(len(l1)):
#     sum+=l1[i]
# avg=sum/20
print(sum(l1))
avg=sum(l1)/20
# print('平均值为：',avg)
l2=[]
for j in range(len(l1)):
    a=avg-l1[j]
    # print(a)
    l2.append(round(a,2))
print(l2)

